#!/bin/bash

echo Start Jlink

JLINK_DEVICE=STM32F030RC
FLASH_START_ADDR=0x08000000
JLinkExe=JLinkExe

LoadFileTargex=$1

echo $1

##

# JLINK_OPTS="-device $JLINK_DEVICE -if swd -speed 4000"
JLINK_OPTS="-device $JLINK_DEVICE -if swd -speed 1800"
JLINK="$JLinkExe $JLINK_OPTS"

printf "loadfile $LoadFileTargex $FLASH_START_ADDR\rr\rg\rexit\r" > jlink/flash.jlink
$JLINK jlink/flash.jlink

#echo "loadfile $LoadFileTargex $(FLASH_START_ADDR)\nr\ng\nexit\n" #> flash.jlink

